package GreedyThought;

// Lettcode 122: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/
public class maxProfitII {
    public int maxProfit(int[] prices) {
        int length = prices.length;
        if (length == 0) return 0;
        int result = 0;
        for (int i = 0; i < length - 1; i++) {
            if (prices[i] < prices[i + 1]) {
                result += (prices[i + 1] - prices[i]);
            }
        }
        return result;
    }
}
